package com.life.ai.server.common.exception;

import cn.hutool.core.util.StrUtil;
import com.life.ai.server.common.exception.errorcode.IErrorCode;
import lombok.Getter;


/**
 * 抽象项目中三类异常体系，客户端异常、服务端异常以及远程服务调用异常
 *
 * @author soupcat
 * @see ClientException
 * @see ServiceException
 * @see RemoteException
 */
@Getter
public abstract class AbstractException extends RuntimeException {

    public final String errorCode;

    public final String errorMessage;

    public AbstractException(IErrorCode errorCode, String message) {
        super(message);
        this.errorCode = errorCode.getCode();
        this.errorMessage = StrUtil.nullToDefault(message, errorCode.getMessage());
    }
}
